﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PDX
{
    /// <summary>
    /// A XAML-friendly list of <see cref="Declaration"/>s.
    /// </summary>
    public class DeclarationList : IDeclarationBuilder
    {
        /// <summary>
        /// Gets or sets a comma-separated list of property paths.
        /// </summary>
        /// <value>
        /// The paths.
        /// </value>
        public string Paths { get; set; }

        /// <summary>
        /// Builds the declarations.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <returns></returns>
        public IEnumerable<Declaration> BuildDeclarations(object target)
        {
            var names = Paths.Split(',');

            foreach (var name in names)
            {
                var dec = new Declaration();
                dec.Path = name;
                yield return dec;
            }

            yield break;
        }
    }
}
